﻿using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JobbJakt
{
    /// <summary>
    /// 
    /// </summary>
   public partial class JobExperience
    {
       /// <summary>
        /// Hämtar ut alla erfarenheter som ha detta argurment username
       /// </summary>
       /// <param name="userName"></param>
       /// <returns></returns>
        public static List<JobExperience> GetJobExperiences(string userName)
        {
            var query = JobbJaktDB.JobExperiences
                .Where(n => n.UserName == userName).ToList();
            return query;
        }
       /// <summary>
       /// 
       /// </summary>
       /// <param name="jobExperience"></param>
       /// <returns></returns>
        public static int InsertJobExperience(JobExperience jobExperience)
        {
            JobbJaktDB.JobExperiences.Add(jobExperience);
            return JobbJaktDB.Save();
        }
       /// <summary>
       /// 
       /// </summary>
       /// <param name="jobExperience"></param>
       /// <returns></returns>
        public static int DeleteJobExperience(JobExperience jobExperience)
        {
            JobbJaktDB.JobExperiences.Remove(jobExperience);
            return JobbJaktDB.Save();
        }
       /// <summary>
       /// 
       /// </summary>
       /// <param name="jobExperience"></param>
       /// <returns></returns>
        public static int UpdateJobExperience(JobExperience jobExperience)
        {
            JobbJaktDB.JobExperiences.AddOrUpdate(jobExperience);
            return JobbJaktDB.Save();
        }
       /// <summary>
       /// 
       /// </summary>
       /// <returns></returns>
       public override string ToString()
       {
           return
               string.Format(
                   "Erfarenhet ID:{0}  Start Datum:{1} Slut Datum:{2} Befattning:{3} Arbetsgivare:{4} Beskrivning:{5} Jobb Typ:{6} Användare Namn:{7}",
                   JobExperienceID, StartDate, EndDate, Position, Employer, Desciption, TypeOfEmployment, UserName);
       }
    }
}
